﻿#ifndef __LINECHART_H__
#define __LINECHART_H__

#include <QWidget>
#include <QPainter>
#include <QBrush>
#include <QPen>
#include <QPropertyAnimation>
#include <QMap>
#include <QList>

class CPoint
{
	friend class LineChart;
private:
	double x;
	double y;
public:
	inline CPoint(int x, int y)
	{
		this->x = x;
		this->y = y;
	}
};

class LineChart : public QWidget
{
	Q_OBJECT
private:
	//指标数据
	QList<CPoint> chart_value;
	//指标颜色（点+连接下一个点的线段）
	QList<QColor> chart_color;
	//指标描述
	QList<QString> chart_desc;
	//图表宽度（需要预留大小）
	int chart_width;
	//图标高度（需要预留大小）
	int chart_height;
	//锚点半径
	int point_radius;
	//y轴最大值
	double y_max;
	//x轴最大值
	double x_max;
	//链接程度
	double link_count;
	//链接动画
	QPropertyAnimation* link_animation;
public:
	explicit LineChart(QWidget* parent = nullptr);
	void addData(CPoint value, const QColor& color, const QString& desc = "Default");
protected:
	void paintEvent(QPaintEvent* event) override;
	void resizeEvent(QResizeEvent* event) override;
	void mousePressEvent(QMouseEvent* event) override;
};



#endif // !__LINECHART_H__
